message dialog: Stop hardcoding title styles
authorMatthias Clasen <mclasen@redhat.com>
Fri, 31 May 2019 12:10:02 +0000 (12:10 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 13 Jun 2019 16:29:29 +0000 (16:29 +0000)
Instead, use a new title style class to let
themes influence title formatting. Note that
the theme style will be overridden if the
application uses markup for presentation,
such as <b> or <i>.

gtk/gtkmessagedialog.c
gtk/theme/Adwaita/_common.scss
gtk/ui/gtkmessagedialog.ui

index 52d40a784c5c77633a860255f7408162df34105d..a74e00123c71ca3dbffd82a17f516af8efb37560 100644 (file)
@@ -292,37 +292,6 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
   gtk_label_set_selectable (GTK_LABEL (priv->secondary_label), use_caret);
 }
 
-static void
-setup_primary_label_font (GtkMessageDialog *dialog)
-{
-  GtkMessageDialogPrivate *priv = gtk_message_dialog_get_instance_private (dialog);
-
-  if (!priv->has_primary_markup)
-    {
-      PangoAttrList *attributes;
-      PangoAttribute *attr;
-
-      attributes = pango_attr_list_new ();
-
-      attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
-      pango_attr_list_insert (attributes, attr);
-
-      if (priv->has_secondary_text)
-        {
-          attr = pango_attr_scale_new (PANGO_SCALE_LARGE);
-          pango_attr_list_insert (attributes, attr);
-        }
-
-      gtk_label_set_attributes (GTK_LABEL (priv->label), attributes);
-      pango_attr_list_unref (attributes);
-    }
-  else
-    {
-      /* unset the font settings */
-      gtk_label_set_attributes (GTK_LABEL (priv->label), NULL);
-    }
-}
-
 static void
 setup_type (GtkMessageDialog *dialog,
            GtkMessageType    type)
@@ -451,7 +420,6 @@ gtk_message_dialog_set_property (GObject      *object,
           gtk_label_set_use_markup (GTK_LABEL (priv->label), priv->has_primary_markup);
           g_object_notify_by_pspec (object, pspec);
         }
-        setup_primary_label_font (dialog);
       break;
     case PROP_SECONDARY_TEXT:
       {
@@ -472,7 +440,6 @@ gtk_message_dialog_set_property (GObject      *object,
            priv->has_secondary_text = FALSE;
            gtk_widget_hide (priv->secondary_label);
          }
-       setup_primary_label_font (dialog);
       }
       break;
     case PROP_SECONDARY_USE_MARKUP:
@@ -719,8 +686,6 @@ gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
       priv->has_secondary_text = FALSE;
       gtk_widget_hide (priv->secondary_label);
     }
-
-  setup_primary_label_font (message_dialog);
 }
 
 /**
@@ -777,8 +742,6 @@ gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
       priv->has_secondary_text = FALSE;
       gtk_widget_hide (priv->secondary_label);
     }
-
-  setup_primary_label_font (message_dialog);
 }
 
 /**
index 1f6398dbc1079663329bbd0783e610ac75e887c7..8bb956bd05420af9b56904f04266185c2bb94b36 100644 (file)
@@ -3822,6 +3822,11 @@ messagedialog { // Message Dialog styling
     border-spacing: 10px;
   }
 
+  & label.title {
+    font-weight: 800;
+    font-size: 15pt;
+  }
+
   &.csd { // rounded bottom border styling for csd version
     &.background {
       // bigger radius for better antialiasing
index 128136bc95e5811bb48e3362c93841cfd79f1aaa..52484587df213676fad0241bd0124dec688c1be0 100644 (file)
@@ -27,6 +27,9 @@
                     <property name="valign">start</property>
                     <property name="wrap">1</property>
                     <property name="max-width-chars">60</property>
+                    <style>
+                      <class name="title"/>
+                    </style>
                   </object>
                 </child>
                 <child>